/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaAjuda.java
 *
 * Created on 04/10/2008, 16:31:30
 */

package sintelo.visao;

import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

/**
 *
 * @author phireis
 */
public class TelaAjuda extends javax.swing.JFrame implements HyperlinkListener{

    /** Creates new form TelaAjuda */
    public TelaAjuda(String pagina) {
        initComponents();
        try {
            URL url = ClassLoader.getSystemResource(pagina);

            htmlPane.setPage(url);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        htmlPane.addHyperlinkListener(this);
    }


    public void hyperlinkUpdate(HyperlinkEvent e){
        if(e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED)
            try
            {
                URL url = e.getURL();
                if(url.toString().endsWith(".html")){
                    htmlPane.setPage(e.getURL());
                }
            }
            catch(IOException e1)
            {
                e1.printStackTrace();
            }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        htmlPane = new javax.swing.JEditorPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Ajuda");

        htmlPane.setEditable(false);
        jScrollPane1.setViewportView(htmlPane);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-624)/2, (screenSize.height-472)/2, 624, 472);
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaAjuda("http://www.google.com").setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JEditorPane htmlPane;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
